package com.coder4j.enums;

import com.coder4j.starter.web.OptionVO;

import java.util.ArrayList;
import java.util.List;

/**
 * 分组类型枚举
 * @author keller
 * @date 2024-5-9 12:31:20
 */
public enum SysGroupTypeEnum {
    Menu("菜单"),
    Dictionary("字典"),
    Configuration("配置"),
    Tag("标签"),
    StatisticsType("统计类型");

    public String title;

    SysGroupTypeEnum(String title) {
        this.title = title;
    }


    /**
     * 获取类型列表
     * @return
     */
    public static List<OptionVO<String>> getTypeList(){
        List<OptionVO<String>> list = new ArrayList<>();
        for (SysGroupTypeEnum type : SysGroupTypeEnum.values()) {
            list.add(new OptionVO<>(type.title,type.name()));
        }
        return list;
    }

    public static String getTitle(String name){
        try {
            return SysGroupTypeEnum.valueOf(name).title;
        }catch (Exception e){
            return null;
        }

    }

    public static boolean contains(String type) {
        try {
            SysGroupTypeEnum.valueOf(type);
            return true;
        }catch (Exception e){
            return false;
        }
    }

}
